package cn.dengta.webapp.user.entity;

import java.util.Date;

import cn.dengta.webapp.base.entity.BaseEntity;
import cn.dengta.webapp.user.model.ContactType;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 招募广告统计
 *
 * @author lgy
 * @since 2022-12-16
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("dt_recruit_ad_statistics")
public class RecruitAdStatistics extends BaseEntity {

	/** 广告ID */
	Long recruitAdId;
	/** 曝光量 */
	Integer exposure;
	/** 点击量（去重） */
	Integer hit;
	/** 点击量(所有) */
	Integer allHit;
	/** 总表单数 */
	Integer submitCount;
	/** whatsApp表单数 */
	Integer whatsAppCount;
	/** telegram表单数 */
	Integer telegramCount;
	/** 下载点击数 */
	Integer download;
	/** iOS下载点击数 */
	Integer iosDownload;
	/** 统计时间 */
	Date reportTime;
	/** 添加时间 */
	Date addTime;

	public RecruitAdStatistics init(Date reportTime, Date now) {
		this.recruitAdId = null;
		this.exposure = 0;
		this.hit = 0;
		this.allHit = 0;
		this.submitCount = 0;
		this.whatsAppCount = 0;
		this.telegramCount = 0;
		this.download = 0;
		this.iosDownload = 0;
		this.reportTime = reportTime;
		this.addTime = now;
		return this;
	}

	public void addHit(ContactType type, boolean addSubmitCount) {
		if (type != null) {
			switch (type) {
				case WHATS_APP:
					whatsAppCount++;
					break;
				case TELEGRAM:
					telegramCount++;
					break;
			}
		}
		if (addSubmitCount) {
			submitCount++;
		}
	}

	public static final String RECRUIT_AD_ID = "recruit_ad_id";
	public static final String EXPOSURE = "exposure";
	public static final String HIT = "hit";
	public static final String ALL_HIT = "all_hit";
	public static final String SUBMIT_COUNT = "submit_count";
	public static final String WHATS_APP_COUNT = "whats_app_count";
	public static final String TELEGRAM_COUNT = "telegram_count";
	public static final String DOWNLOAD = "download";
	public static final String REPORT_TIME = "report_time";
	public static final String ADD_TIME = "add_time";

}
